Default versioned API functions to earliest version for older API settings#6280
Open
brtnfld wants to merge 8 commits intoHDFGroup:developfrom
Open
Default versioned API functions to earliest version for older API settings#6280brtnfld wants to merge 8 commits intoHDFGroup:developfrom
brtnfld wants to merge 8 commits intoHDFGroup:developfrom
Conversation
…tings (HDFGroup#6278) When a global API version is set (e.g., H5_USE_16_API), functions introduced after that version now default to their earliest version (version 1) instead of the latest. This prevents breakage when an application uses an older API setting but calls functions that were later versioned. - Update bin/make_vers to populate version 1 for API levels predating a function's introduction - Regenerate src/H5version.h with the new defaults - Add auto-generated test (test/tapi_version_default.c) produced by make_vers, compiled once per API version level (v16 through v200), verifying all _vers macros match expected values - Register the test variants in test/CMakeLists.txt and test/CMakeTests.cmake Fixes HDFGroup#6278
Replace three parallel lists with ZIP_LISTS (requires CMake 3.17) with a single API_VERSION_TEST_NUMBERS list, deriving the target name and compile definitions dynamically from the number.
- Remove harmful quotes around list variables in target_compile_options and target_compile_definitions so CMake expands them correctly - Remove duplicated API_VERSION_TEST_NUMBERS definition from CMakeTests.cmake; it is already in scope via include() from CMakeLists.txt
- Use TESTING()/PASSED()/H5_FAILED() macros in the generated tapi_version_default.c for consistency with other HDF5 tests - Validate the src/ -> test/ directory substitution in make_vers create_test() to fail early if the prefix is unexpected - Add clarifying comment in test/CMakeLists.txt explaining why ADD_H5_EXE cannot be reused for the API version default tests
Collaborator
Author
|
The netCDF tst_h_files4.c is calling H5Oopen_by_token and accessing info->u.token, which requires H5O_info2_t (version 2 of the struct, introduced in v1.12). But the build is getting H5O_info1_t (version 1), which has info->u.addr instead of info->u.token. netcdf needs to:
|
When CI configures with a global default API version (e.g., HDF5_DEFAULT_API_VERSION=v16), H5pubconf.h defines H5_USE_16_API_DEFAULT which activates H5_USE_16_API in H5version.h. This caused tests for newer API versions (v200, etc.) to fail because multiple H5_USE_*_API blocks were active simultaneously and the earliest one won. Fix by having the generated test include H5pubconf.h first, #undef all API version macros, then re-establish only the version under test before including the remaining headers.
Collaborator
Author
|
NetCDF fix, Unidata/netcdf-c#3310 |
Collaborator
Author
|
NetCDF has been patched. |
lrknox
approved these changes
Mar 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #6278
The fix in bin/make_vers:
For every API version older than a function's introduction version, it now explicitly sets _vers = 1 (earliest). This means:
H5_USE_16_API -> H5Sencode_vers = 1 -> maps to H5Sencode1 (instead of falling through to H5Sencode2)
H5_USE_16_API -> H5Dread_chunk_vers = 1 -> maps to H5Dread_chunk1 (introduced v1.10, versioned in v2.0.0)
Functions already introduced at or before the configured API version are unchanged.
The auto-generated test in test/tapi_version_default.c validates this for every function × API-version combination by compiling the test six times (once per API level: v16, v18, v110, v112, v114, v200) and asserting each _vers macro equals the expected value.